

package net.sourceforge.jsorter;

import java.util.*;

/**
 *
 * @author  Jason Rutherglen
 */
public class ReflectColumns {
  public List<SortableColumn> list = new ArrayList<SortableColumn>();
  
  public ReflectColumns() {
  }
  
  public SortReflect[] getSortReflects() {
    SortReflect[] sortReflects = new SortReflect[list.size()];
    int count = 0;
    Iterator iterator = list.iterator();
    while (iterator.hasNext()) {
      SortableColumnReflect sortableColumnReflect = (SortableColumnReflect)iterator.next();
      sortReflects[count] = sortableColumnReflect.sortReflect;
      
      count++;
    }
    return sortReflects;
  }
  
  public List<SortableColumn> getColumns() {
    return list;
  }
  
  public class SortableColumnReflect implements SortableColumn {
    int position;
    String name;
    SortReflect sortReflect;
    int order;
    
    public SortableColumnReflect(int position, String name, SortReflect sortReflect, int order) {
      this.position = position;
      this.name = name;
      this.sortReflect = sortReflect;
      this.order = order;
    }
    
    public String getColumnName() {
      return name;
    }
    
    public int getColumnOrder() {
      return order;
    }
    
    public int getColumnPosition() {
      return position;
    }
  }
  
  public void add(String name, SortReflect sortReflect, int order) {
    SortableColumnReflect sortableColumnReflect = new SortableColumnReflect(list.size(), name, sortReflect, order);
    list.add(sortableColumnReflect);
  }
}
